<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:se="http://java.sun.com/jsf/composite/inward/search">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel header="Search Bills" >
                        <f:facet name="header" >
                            <h:panelGroup>
                                <h:panelGrid columns="5">

                                    <p:commandButton ajax="false" action="#{dataAdministrationController.createInwardServiceBillWithPaymentmethord}" value="Search" onclick="onSubmitButton();" />
                                    <p:commandButton ajax="false" action="#{dataAdministrationController.updateInwardServiceBillWithPaymentmethord}" value="Update" onclick="onSubmitButton();" />
                                </h:panelGrid>

                            </h:panelGroup>
                        </f:facet>

                        <p:dataTable id="tblBills" 
                                     value="#{dataAdministrationController.bills}" 
                                     var="bill"
                                     selection="#{dataAdministrationController.selectedBills}"
                                     rowIndexVar="i"
                                     rowKey="#{bill.id}"
                                     rowStyleClass="#{bill.paymentMethod eq 'Card' ? 'greenText':''}"
                                     >    
                            <p:column  selectionMode="multiple" >                            
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <p:outputLabel value="No" />
                                </f:facet>
                                <p:outputLabel value="#{i+1}" />
                            </p:column>
                            <p:column headerText="Bill No(insId)">                               
                                <h:outputLabel value="#{bill.insId}"></h:outputLabel>                                
                            </p:column>
                            <p:column headerText="Bill No(deptId)">                               
                                <h:outputLabel value="#{bill.deptId}"></h:outputLabel>                                
                            </p:column>
                            <p:column headerText="Bht No">                              
                                <h:outputLabel value="#{bill.patientEncounter.bhtNo}"  ></h:outputLabel>                                    
                            </p:column>

                            <p:column headerText="Bill Date" >
                                <h:outputLabel value="#{bill.createdAt}" >
                                    <f:convertDateTime pattern="yyyy MM  dd - hh:mm:ss a"/>
                                </h:outputLabel>
                                <br/>
                                <h:panelGroup rendered="#{bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="yyyy MM  dd - hh:mm:ss a"/>
                                    </h:outputLabel>
                                </h:panelGroup>        
                            </p:column>

                            <p:column headerText="Billed By">  
                                <h:outputLabel value="#{bill.creater.webUserPerson.name}" >                                      
                                </h:outputLabel>                                  
                                <br/>
                                <h:panelGroup rendered="#{bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled By " />
                                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.creater.webUserPerson.name}" >                                       
                                    </h:outputLabel>
                                </h:panelGroup>
                            </p:column>

                            <p:column headerText="BHT Total Value">
                                #{bill.paymentMethod}
                            </p:column>
                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
